package y_2025.m07.d25;

import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;

public class RefrerenceTest {


    //1、强引用
    static Person p = new Person();

    //2、软引用
    static SoftReference<Person> softReference = new SoftReference<>(new Person());


    //3、弱引用
    static WeakReference<Person> weakReference = new WeakReference<>(new Person());


    //4、虚引用
    static PhantomReference<Person> personPhantomReference = new PhantomReference<>(p,new ReferenceQueue<>());


    public static void main(String[] args) {
        Person person = softReference.get();
        System.out.println(person);


        Person person1 = weakReference.get();
        System.out.println(person1);


        Person person2 = personPhantomReference.get();
        System.out.println(person2);

    }
}

class Person{

}
